<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>在一个路由中设置“路径参数”</title>
    <!--引入Vue库-->
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
  </head>
  <body>
    <div id="app">
      <p>
        <router-link to="/user/admin">/user/admin</router-link>
        <router-link to="/user/better">/user/better</router-link>
      </p>
      <router-view></router-view>
    </div>
    <script>
      const User = {
        template: `<div>当前用户： {{ $route.params.id }}</div>`,
      };
      const router = new VueRouter({
        routes: [{ path: "/user/:id", component: User }],
      });
      const app = new Vue({ router }).$mount("#app");
    </script>
  </body>
</html>
